#ifndef __POSITION_H__
#define __POSITION_H__

#include <vector>
#include <cassert> // assert
#include <cstddef> //size_t

/// Coordinate of a position
class Position
{
  /// Coordinates and number of dimensions
  enum {X=0, Y, NDIM};
private:
  std::vector<size_t> coordinate_;
public:
  /// default constructor
  Position():coordinate_(NDIM) {}
  /// Copy constructor
  Position(const Position &pos) : coordinate_(pos.coordinate_)
    { assert(coordinate_.size()==NDIM); }
  /// constructor
  Position(const size_t x, const size_t y) : coordinate_(NDIM)
    { coordinate_[X] = x; coordinate_[Y] = y; }
  /// destructor
  ~Position() {}
public:
  Position &operator=(const Position &pos)
    {
      if (&pos != this) // avoid self-assignment
	coordinate_ = pos.coordinate_;
      return *this;
    }
  /// get coordinate X
  size_t x() const { return coordinate_.at(X); }
  /// set coordinate X
  size_t x(const size_t val) { return (coordinate_[X] = val); }
  /// get coordinate Y
  size_t y() const { return coordinate_.at(Y); }
  /// set coordinate Y
  size_t y(const size_t val) { return (coordinate_[Y] = val); }
};

#endif //__POSITION_H__
